package com.itheima.d6_TCP;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws Exception {
        // 创建Socket管道
        ServerSocket serverSocket = new ServerSocket(7777);
        // 建立socket通信管道
        Socket socket = serverSocket.accept();
        // 获取数据了
        InputStream inputStream = socket.getInputStream();
        // 把字节输入流包装成缓冲字符输入流进行消息的接受
        BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));


        String s = br.readLine();
        if (s!=null) {
            System.out.println(socket.getRemoteSocketAddress()+":"+s);
        }
    }
}
